﻿using System;

namespace Entropy.Proxy
{
    public class RealProxyBasedFactory : IProxyFactory
    {
        public T CreateProxy<T>(T intf, RemotingInvocation callback)
        {
            var proxy = new RealProxyBased(intf, callback);
            var transparentProxy = proxy.GetTransparentProxy();
            return (T)transparentProxy;
        }

        public T CreateProxy<T>(RemotingInvocation callback)
        {
            var proxy = new RealProxyBased(null, callback);
            var transparentProxy = proxy.GetTransparentProxy();
            return (T)transparentProxy;
        }

        public object CreateProxy(Type type, RemotingInvocation callback)
        {
            var proxy = new RealProxyBased(null, callback);
            var transparentProxy = proxy.GetTransparentProxy();
            return transparentProxy;
        }
    }
}